package com.vodone.v1pin.component.container
{
	import mx.controls.Text;
	
	public class VideoText extends Text
	{
		public function VideoText()
		{
			super();
		}
		public var hLines:int = 2;
		
		public override function set text(value:String):void
		{
			super.text = value;
			this.invalidateDisplayList();
		}
		
		protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
		{
			super.updateDisplayList(unscaledWidth,unscaledHeight);
			if(this.width <= 0)return;
			var textWidth:Number = this.measureText( this.text ).width;
			if( (textWidth / this.width) >= hLines)
			{
				this.toolTip = this.text;
				var ltext:String = this.text;
				var str:String = "";
				for(var i:int = ltext.length - 1 ; i >= 0; i--)
				{
					str = ltext.substr(0,i);
					if(this.measureText( str ).width < this.width * hLines && i > 4)
					{
						this.text = ltext.substr(0,i - 4) + "...";
						break;
					}
				}
			}
			
		}
	}
}